package logic

import (
	"context"
	"house/model/mysql"

	"house/house"
	"house/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ReservationListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewReservationListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ReservationListLogic {
	return &ReservationListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ReservationListLogic) ReservationList(in *house.ReservationListRequest) (*house.ReservationListResponse, error) {
	// todo: add your logic here and delete this line
	var r []mysql.Reservation
	mysql.DB.Find(&r)
	var list []*house.ReservationList
	for _, k := range r {
		list = append(list, &house.ReservationList{
			ReservationSn:      k.ReservationSn,
			ReservationRealkey: k.ReservationRealkey,
			UserId:             int64(k.UserId),
			ReservationStatus:  k.ReservationStatus,
		})
	}
	return &house.ReservationListResponse{
		List: list,
	}, nil
}
